package com.itts.hk.theard.Demo;

import com.alibaba.fastjson.JSON;
import com.itts.hk.map.GaoUtils;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * MapThread线程类, 继承Callable接口
 * @author ouyangjun
 */
public class MapThread implements Callable<String> {

    private List<Point2D.Double> lists;
    private List<Point2D.Double> list;

    /** 初始化map, 传值可各种各样 */
    public MapThread(List<Point2D.Double> lists, List<Point2D.Double> list) {
        this.lists = lists; // 范围
        this.list = list;//测试的点
    }

    /** 返回字符串, 也可以把对象转化成json字符串返回
     * @return*/
    public String call(){
        // 做具体的业务逻辑
        List<Point2D.Double> arrayList= new ArrayList<Point2D.Double>();
        for (Point2D.Double aDouble : list) {
            boolean b = GaoUtils.IsPtInPoly(aDouble, lists);
            if (b){
                arrayList.add(aDouble);
            }
        }
        return JSON.toJSONString(arrayList.toString());
    }
}
